<template>
  <div style="padding:3%">
      <el-row>
          <el-col :span="12">
              <el-form :model="form" ref="keyCarForm" label-width="200px">
                <el-form-item v-for="(v,k,i) in form" :label="labels[i]" :key="i" :prop="k">
                    <el-select v-if="k=='netGridID'" v-model="form[k]">
                        <el-option v-for="v in netGridType" :key="v.id" :value="v.netGridID" :label="v.netGridName"></el-option>
                    </el-select>
                    <el-input autosize v-else-if="k=='remarks'||k=='insuranceInf'||k=='yearCheckInf'" v-model="form[k]" type="textarea"></el-input>
                    <el-input v-else v-model="form[k]"></el-input>
                </el-form-item>
                <el-form-item align="center">
                    <el-button type="warning">重置</el-button>
                    <el-button type="primary" @click="updateRecord">更新</el-button>
                </el-form-item>
              </el-form>
          </el-col>
      </el-row>
  </div>
</template>

<script>
import * as api from "@/api/videoManage";
import * as api2 from "@/api/securityManage";

export default {
  data() {
    return {
      num: 4,
      form: {
        scenicAreaDutyPointID:'',
        scenicAreaDutyPointName:'',
        netGridID:'',// '景区执勤点所属网格区域',
        scenicAreaDutyPointLongitude:'',// comment '执勤点 地理经度信息',
        scenicAreaDutyPointLatitude:''// comment '执勤点 地理纬度信息',
      },
      labels: ["编号", "执勤点名称", "所属网格", "所属经度", "所属纬度"],
      netGridType: []
    };
  },
  methods: {
    updateRecord() {
      api2.updateDutyPoint(this.form).then(res => {
        if (res.data) {
          this.$message({
            type: "success",
            message: "更新成功!"
          });
        } else {
          this.$message({
            type: "error",
            message: res.message
          });
        }
      });
    }
  },
  mounted() {
    let id = this.$route.query.id;
    api.fetchNetGrid().then(res => {
      this.netGridType = res.data;
    });
    api2.getDutyDetailToUpdate(id).then(res=>{
        this.form = res.data
    })
  }
};
</script>

<style scoped>

</style>
